#include <stdio.h>
#include <stdlib.h>

typedef struct StackNode
{
    int data;
    struct StackNode *next;
} StackNode_t, *StackNode_p;

typedef struct Stack
{
    StackNode_p top;
    int size;
} Stack_t, *Stack_p;

StackNode_p createNode(int data)
{
    StackNode_p newNode = (StackNode_p)malloc(sizeof(StackNode_t));
    newNode->data = data;
    newNode->next = NULL;
    return newNode;
}

void push(Stack_p stack, int data)
{
    StackNode_p newNode = createNode(data);
    newNode->next = stack->top->next;
    stack->top->next = newNode;
    stack->size++;
}

void printStack(Stack_p stack)
{
    StackNode_p p = stack->top->next;
    while (p)
    {
        printf("%d ", p->data);
        p = p->next;
    }
    printf("size:%d", stack->size);
    printf("\n");
}

void pop(Stack_p stack)
{
    StackNode_p p = stack->top->next;
    if (p == NULL)
    {
        return;
    }
    stack->top->next = p->next;
    free(p);
    stack->size--;
}

Stack_p initStack()
{
    Stack_p stack = (Stack_p)malloc(sizeof(Stack_t));
    stack->top = createNode(0);
    stack->size = 0;
    return stack;
}

int main()
{
    Stack_p s1 = initStack();
    push(s1, 11);
    push(s1, 22);
    push(s1, 33);
    printStack(s1);
    pop(s1);
    printStack(s1);
}